package com.twu.biblioteca;

public class Library {

    protected Shelf reservedBooks;
    protected Shelf availableBooks;
    protected Shelf movieShelf;

    public Library(Shelf bookShelf, Shelf movieShelf) {
        this.availableBooks = bookShelf;
        this.reservedBooks = new Shelf();
        this.movieShelf = movieShelf;
    }

    public boolean reserve(String title) {
        Book reservedBook = (Book) availableBooks.getByTitle(title);
        if (reservedBook != null) {
            if (reservedBooks.add(reservedBook)) {
                availableBooks.remove(reservedBook);
                return true;
            }

        }
        return false;
    }

    protected int countAvailableBooks() {
        return availableBooks.count();
    }


    public int countReservedBooks() {
        return reservedBooks.count();
    }

    public String showAvailableBooks() {
        return availableBooks.display();
    }

    public String displayMovies() {
        return movieShelf.display();
    }
}
